package com.fishery.quartz.config;

import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.net.HttpURLConnection;

/**
 * 解决RestTemplate使用exchange发送DELTE请求携带请求体问题
 */
@Component
public class MyClientHttpRequestFactory extends SimpleClientHttpRequestFactory {

	@Override
	protected void prepareConnection(HttpURLConnection connection, String httpMethod) throws IOException {
		super.prepareConnection(connection, httpMethod);
		if ("DELETE".equalsIgnoreCase(httpMethod)) {
			connection.setDoOutput(true);
		}
	}
}
